package com.sgsg.designmodetest;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

/****
 * 观察者模式
 */

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SubjectA subject = new SubjectA();

        subject.addObserver(new ObserverA(subject,"观察者一"));
        subject.addObserver(new ObserverB(subject,"观察者二"));

        subject.setSubjectState("今天是星期天");
        subject.Notify();

    }
}
